package com.conncui.common.json.impl;

import com.alibaba.fastjson.JSON;
import com.conncui.common.json.dao.Json;

import java.util.List;

/**
 * Created by cui on 16-3-1.
 */
public class FastJsonImpl implements Json {
    @Override
    public String objectToString(Object object) {
        return JSON.toJSONString(object);
    }

    @Override
    public <T> T stringToObject(String jsonString, Class<T> tClass) {
        return JSON.parseObject(jsonString,tClass);
    }

    @Override
    public <T> List<T>  stringToObjectList(String jsonString, Class<T> tClass) {
        return JSON.parseArray(jsonString,tClass);
    }

    @Override
    public String objectListToString(Object objectList) {
        return JSON.toJSONString(objectList);
    }
}